import { loadOrgTags } from './api.js'
import StorageUtil from 'party_fe_component/src/assets/js/utils/storageUtil'

const util = new StorageUtil(sessionStorage)
const key = 'orgTagNames'

export default {
    data() {
        return {
            fgTagNames: {}
        }
    },
    created() {
        let tagNames = util.getObj(key)
        if (tagNames) {
            this.fgTagNames = tagNames
        } else {
            tagNames = {} //放ajax外面，避免重复加载
            loadOrgTags().then(res => {
                var list = res.data || []
                list.map(tag => {
                    tagNames[tag.id] = tag.name
                })
                this.fgTagNames = tagNames
                util.setObj(key, tagNames)
            })
        }
    },
}
